import React, { VFC, useEffect, useState} from "react"
import { Select } from 'antd';
const { Option } = Select;
type ItemType = {
    name:string
    id:number
}
type PropsType = {
    dataList:any[]
    selectValue?: string
    onChange:(e:any) => void
    type?: string,
    mode?: "multiple" | "tags" | undefined
}
const mySelect:VFC<PropsType> = props => {
    const {dataList, mode, onChange, selectValue} = props;
    const [projectAllList, setProjectAllList] = useState<any[]>([]);
    useEffect(()=>{
        setProjectAllList(dataList)
    },[dataList])

    const onSelectChange = (e: any) => {
        onChange(e)
    }
    return (
        <Select placeholder="请选择" value={selectValue} mode={mode} style={{ width: mode?'100%':120 }} onChange={onSelectChange}>
            {
                projectAllList?.length>0&&projectAllList.map((item:ItemType,index:number)=>(
                    <Option value={item.id} key={index}>{item.name}</Option>
                ))
            }
        </Select>
    )
}
export default mySelect